package com.wondersgroup.framework.sample.component.grid.action;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.sf.json.JSONObject;

public class TreeGridAction extends BaseAjaxAction {
	private String[] treeNodes;

	public TreeGridAction() {
		this.treeNodes = new String[] { "教育部", "科技部", "卫生部", "住建部" };
	}

	protected String operate() {
		Date date = new Date();
		List list = new ArrayList(4);
		for (int i = 0; i < 4; ++i) {
			JSONObject data = new JSONObject();
			data.put("organization", this.treeNodes[i]);
			data.put("id", Long.valueOf(date.getTime() + i));
			data.put("orgLevel", "未定");
			data.put("createTime", "2010-03-05");
			list.add(data);
		}
		return "{result: " + VOUtils.getJsonDataFromCollection(list) + "}";
	}
}